package day12_homework;

import java.util.Scanner;

public class Test {
	public static void main(String[] args) throws NegativeSquareException{
		Scanner input = new Scanner(System.in);
		System.out.println("请输入需要计算的数字：");
		double num = input.nextDouble();
			if (num >= 0) {
				System.out.println(num+"的平方根是："+Math.sqrt(num));
			} else {
				throw new  NegativeSquareException();
			}
		
	}
//	public static void main(String[] args) {
//		Scanner input = new Scanner(System.in);
//		System.out.println("请输入需要计算的数字：");
//		try {
//			double num = input.nextDouble();
//			if (num >= 0) {
//				System.out.println(num+"的平方根是："+Math.sqrt(num));
//			} else {
//				System.out.println(num+"的平方根是："+Math.sqrt(num));
//			}
//			
//		} catch (NegativeSquareException e) {
//			System.out.println("输入错误，不能对负数求平方根!");
//		}
//	}
}
